/**
 *  This file is part of PennerBot
 *
 *  Copyright (C) 2010 microkernel
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#include <wx/mstream.h>

#include <core/version.hpp>

#include <gui/logindialog.hpp>
#include <gui/icon.h>

namespace PBot
{
namespace GUI
{

LoginDialog::LoginDialog(Core::Config* cfg)
 : DlgLogin(NULL)
{
    txtUsername->SetValue(wxString(cfg->username.c_str(), wxConvUTF8));
    txtPassword->SetValue(wxString(cfg->password.c_str(), wxConvUTF8));
    chcGame->Select(cfg->game);
    txtUserAgent->SetValue(wxString(cfg->userAgent.c_str(), wxConvUTF8));
    txtProxy->SetValue(wxString(cfg->proxy.c_str(), wxConvUTF8));

    // Main icon
    wxMemoryInputStream iconstream(icon, size_icon);
    wxIcon icoIcon;
    icoIcon.CopyFromBitmap(wxImage(iconstream, wxBITMAP_TYPE_ICO, -1));
    SetIcon(icoIcon);

    SetTitle(wxT("PennerBot ") + wxString(__PBOT_GUI_VERSION__, wxConvUTF8));
}

wxString LoginDialog::GetUsername() const
{
    return txtUsername->GetValue();
}

wxString LoginDialog::GetPassword() const
{
    return txtPassword->GetValue();
}

wxString LoginDialog::GetUserAgent() const
{
    return txtUserAgent->GetValue();
}

Core::Config::Games LoginDialog::GetGame() const
{
    return static_cast<Core::Config::Games>(chcGame->GetSelection());
}

wxString LoginDialog::GetProxy() const
{
    return txtProxy->GetValue();
}

}
}
